package top.tangyh.lamp.care.mapper;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import top.tangyh.basic.base.mapper.SuperMapper;
import top.tangyh.lamp.care.entity.BPgpf;
import org.springframework.stereotype.Repository;
import top.tangyh.lamp.care.vo.query.PgpfQueryVO;
import top.tangyh.lamp.common.constant.CommonConstant;

import java.util.List;
import java.util.Set;

/**
 * <p>
 * Mapper 接口
 * 评估评分配置主表
 * </p>
 *
 * @author zqb
 * @date 2024-07-09 11:07:34
 * @create [2024-07-09 11:07:34] [zqb] [代码生成器生成]
 */
@Repository
public interface BPgpfMapper extends SuperMapper<BPgpf> {

    default List<BPgpf> selectListByQuery(List<Long> pgpfIdList, PgpfQueryVO queryVO) {
        String pgpfName = queryVO.getPgpfName();
        Integer enabled = queryVO.getEnabled();
        Integer bzEnabled = queryVO.getBzEnabled();
        Integer bzDxEnabled = queryVO.getBzDxEnabled();
        List<String> roleId = queryVO.getRoleId();
        LambdaQueryWrapper<BPgpf> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(CollectionUtil.isNotEmpty(pgpfIdList), BPgpf::getId, pgpfIdList)
                .like(StrUtil.isNotBlank(pgpfName), BPgpf::getPgName, pgpfName)
                .eq(enabled != null, BPgpf::getEnabled, enabled)
                .eq(bzEnabled != null, BPgpf::getBzEnabled, bzEnabled)
                .eq(bzDxEnabled != null, BPgpf::getBzDxEnabled, bzDxEnabled)
                .in(CollectionUtil.isNotEmpty(roleId), BPgpf::getRoleId, roleId)
                .eq(BPgpf::getIsDeleted, queryVO.getIsDeleted())
                .orderByDesc(BPgpf::getOrderNo)
                .orderByAsc(BPgpf::getId);

        return this.selectList(queryWrapper);
    }


    default List<BPgpf> selectListByIds(Set<Long> ids){
        LambdaQueryWrapper<BPgpf> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(ids != null && !ids.isEmpty(), BPgpf::getId, ids)
                .eq(BPgpf::getIsDeleted, CommonConstant.NO_NUMBER);
        return selectList(queryWrapper);
    }
}


